/*
 * client.h
 *
 *  Created on: 2012-01-05
 *      Author: mateusz
 */

#ifndef CLIENT_H_
#define CLIENT_H_

#include "shared.h"

#define COMMAND_LINE_HEIGHT 3
#define STATS_WIDTH 30
#define SUBWINDOWS 3
#define MAX_COMMAND_LENGTH 100
#define MAX_LOGS 20
#define CLIENT_QUEUE_ID 2144

WINDOW* create_newwin(int height, int width, int starty, int startx);
void destroy_win(WINDOW *local_win);
void logger(int getQueue, int clientQueue, int shmid);
void stats(int getQueue, int clientQueue, int shmid);
void command(int privateQueue, int clientQueue, int shmid);
void updateScreen(int clientQueue, int shmid);
void newCommand(int privateQueue, char* cmd);
void updateCommandWindow(WINDOW *win, char* cmd);
void updateLogWindow(WINDOW *win, int c);
void updateStatsWindow(WINDOW *win);
void cleanEverything();
void stop();
void newLog(char* newLog);

enum clientMsgs {
	C_NEW_LOG, C_NEW_STATS, C_NEW_COMMAND, C_EXIT_COMMAND, C_EXIT_FROM_SERVER
};

// array of messages under logMessages enums
char* msgs[] = { "", "Server does not exist. Application will exit.",
		"Usage: create [-l|-h|-c|-w] to create units, attack [-l|-h|-w] to attack, exit to exit",
		"Waiting for all players.", "Logs", "Statistics", "Command", "Welcome!", "Entities will be created.",
		"You have not enough supplies to create this entities.", "Winner. Program will exit",
		"Exit is coming", "Not enough units to make attack", "Attack!!",
		"You were attacked. Lost units: LI: %d, HI: %d, C: %d", "Units are back: LI: %d, HI: %d, C: %d",
		"" };

char* entities_strings[] = { "Supplies", "Workers", "Light infantry", "Heavy infantry", "Cavalry", "Wins" };

// shm
struct shm {
	char logs[MAX_LOGS][MAX_LOG_LENGTH];
	int units[LAST_ENTITY + 1];
	char command[MAX_COMMAND_LENGTH];
	int logsCount;
	int wins;
};
struct shm shm;

// commands
char* quitCommand = "exit";
char* createOptions = "w:l:h:c:";
char* attackOptions = "l:h:c:";
char* createCommand = "create";
char* attackCommand = "attack";
char* helpCommand = "help";

extern char *optarg;
extern int optind, optopt;

// curses semaphore
#define SHM_SEM_ID 666
#define SHM_ID 4323
#endif /* CLIENT_H_ */
